﻿using HY.Common;
using HY.DataAchieve;
using HY.Entity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HY.Service
{
    public class HomeService : BaseService
    {
        /// <summary>
        /// 获取用户登录信息
        /// </summary>
        /// <param name="userName">用户名</param>
        /// <param name="password">密码</param>
        /// <returns></returns>
        public V_UserInfo UserLogin(string userName, string password)
        {
            string sqlStr = "SELECT SU.ID UserID,SU.UserName,SD.ID DeptID,SD.DeptName,SR.ID RoleID,SR.RoleName FROM SysUser SU LEFT JOIN SysDept SD ON SU.DeptID=SD.ID LEFT JOIN SysRole SR ON SU.RoleID=SR.ID WHERE SU.UserName=@UserName AND SU.Password=@Password";
            using (UnitOfWork unit = new UnitOfWork())
            {
                V_UserInfo v_UserInfo = unit.Dapper().QueryFirstOrDefault<V_UserInfo>(sqlStr, new { UserName = userName, Password = EncryptHelper.MD5Encrypt(password) });
                return v_UserInfo;
            }
        }
    }
}
